<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>教师管理</title>
	<meta name="decorator" content="default"/>
	<%@ include file="/WEB-INF/views/include/dialog.jsp"%>
	<script type="text/javascript">
	$(document).ready(function() {
		$("#btnExport").click(function(){
			top.$.jBox.confirm("确认要导出学生数据吗？","系统提示",function(v,h,f){
				if(v=="ok"){
					$("#searchForm").attr("action","${ctx}/dd/ddTeacher/export");
					$("#searchForm").submit();
				}
			},{buttonsFocus:1});
			top.$('.jbox-body .jbox-icon').css('top','55px');
		});
		$("#btnImport").click(function(){
			$.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
				bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
		});
	});
		function page(n,s){
			if(n) $("#pageNo").val(n);
			if(s) $("#pageSize").val(s);
			$("#searchForm").attr("action","${ctx}/dd/ddTeacher/list");
			$("#searchForm").submit();
	    	return false;
	    };
	    
		function setDowmUrl(){
			var url='${ctxStatic}'+"/xls/教师表.xlsx";
			location.href =url;
	    };
		
        function showDialog() {
    		$("#info").val();
    		$("#dialog").dialog({
    			modal : true
    		}, {
    			title : "绑定操作"
    		}, {
    			show : {
    				effect : 'drop',
    				direction : 'up'
    			}
    		}, {
    			width : "500"
    		}, {
    			height : "200"
    		});
    	};
	</script>
</head>
<body>
	<div id="importBox" class="hide">
		<form id="importForm" action="${ctx}/dd/ddTeacher/import" method="post" enctype="multipart/form-data"
			class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
			<input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
			<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
			<%-- <a href="${ctx}/dd/ddStudent/import/template">下载模板</a> --%>
			<a id="dowmTable" href="javascript:;" onclick="setDowmUrl();">下载模板</a>
		</form>
	</div>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/dd/ddTeacher/">教师列表</a></li>
		<shiro:hasPermission name="dd:ddTeacher:edit"><li><a href="${ctx}/dd/ddTeacher/form">添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="ddTeacher" action="${ctx}/dd/ddTeacher/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>教师姓名：</label>
				<form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/>
			</li>
			<li><label>教师号：</label>
				<form:input path="id" htmlEscape="false" maxlength="50" class="input-medium"/>
			</li>
			<li><label>专业：</label>
				<form:input path="major" htmlEscape="false" maxlength="50" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
			<input id="btnImport" class="btn btn-primary" type="button" value="导入"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>教师姓名</th>
				<th>性别</th>
				<th>所属学校</th>
				<th>专业</th>
				<th>联系电话</th>
				<th>手机号码</th>
				<th>微信号</th>
				<shiro:hasPermission name="dd:ddTeacher:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="ddTeacher">
			<tr>
				<td><a href="${ctx}/dd/ddTeacher/form?id=${ddTeacher.id}">
					${ddTeacher.name}
				</a></td>
				<td>
					${fns:getDictLabel(ddTeacher.sex, 'sex',1)}
				</td>
				<td>
					${fns:getSchoolName(ddTeacher.schoolId)}
				</td>
				<td>
					${ddTeacher.major}
				</td>
				<td>
					${ddTeacher.contactPhone}
				</td>
				<td>
					${ddTeacher.mobile}
				</td>
				<td>
				${fns:isWeiXin(ddTeacher.createBy.id)}
				</td>
				<shiro:hasPermission name="dd:ddTeacher:edit"><td>
    				<a href="${ctx}/dd/ddTeacher/form?id=${ddTeacher.id}" title="修改">修改</a>
    				<a href="javascript:;" onclick="showDialog();" title="绑定微信">微信</a>
					<a href="${ctx}/dd/ddTeacher/delete?id=${ddTeacher.id}" onclick="return confirmx('确认要删除该单表吗？', this.href)" title="删除">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	
	
	<div id="dialog" style="display:none;">
		<form class="form-horizontal" role="form" id="f_bind"
			action="${ctx}/dd/ddParent/bind" method="post">
			<input type="hidden" id="" name="" />
			<div class="clearfix" style="height: 20px"></div>
			<div class="control-group">
				<label class="control-label"><b
					style="color: red; font-size: large">*</b>微信绑定:</label> 
					&nbsp; <input class="input-medium" id="info" name="info"
					placeholder="请输入" required="required" min="0" />
			</div>
			<div class="clearfix" style="height: 10px"></div>
			<div class="control-group" style="width: 15%; margin:auto;">
				<input type=button id="bindSubmit" class="" value="提交" />
			</div>
		</form>
	</div>
	<script>
		$(function() {
			$('#bindSubmit').click(function() {//点击按钮提交
				$.ajax({
					url : "${ctx}/dd/ddParent/bind",
					data : $("#f_bind").serialize(),
					type : "post",
					success : function(data) {//ajax返回的数据
						alert(data);
						$("#dialog").dialog('close');
					},
					error : function(data) {//ajax返回的数据
						alert(data);
						$("#dialog").dialog('close');
					}
				});
			});

		});
	</script>
</body>
</html>